let HtmlWebpackPlugin = require("html-webpack-plugin");
let htmlPlugin = new HtmlWebpackPlugin({
    filename:"index.html",
    template:"./public/index.html"
})
module.exports = {
    mode: "development",
    entry: "./src/index.js",
    output: {
        filename: "bulid.js",
        path: __dirname + "/dist"
    },
    module: {
        rules: [
            {
                test: /\.css$/i,
                use: ["style-loader", "css-loader"]
            }, {
                test: /\.(png|svg|jpg|jpeg|gif)$/i,
                type: 'asset/resource',
            },
            {
                test: /\.(js|jsx)$/,
                exclude: /(node_modules|bower_components)/,
                use: {
                  loader: 'babel-loader',
                  options: {
                    presets: ['@babel/preset-env','@babel/preset-react']
                  }
                }
              }
        ]
    },
    plugins: [htmlPlugin],
    devServer:{
        port:9090,
        open:true,
        proxy:{
            "/maoyan":{
                // 代理的服务器地址
                target:"https://i.maoyan.com",
                // 是否允许跨域
                changeOrigin:true,
                // 路径重写
                pathRewrite: { '^/maoyan': '' },
            },
            '/douban':{
                target:"https://movie.douban.com",
                changeOrigin:true,
                pathRewrite:{
                    '^/douban':''
                }
            }
        }
    }
}